package com.tssup.fesco.ofc;

import com.tssup.fesco.service.SchedulService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHander;
import com.xxl.job.core.log.XxlJobLogger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by haomin on 2017/3/28.
 * 用于将已审核订单添加到拆单消息队列中
 */
@JobHander(value="OrderSplitJob")
@Service
public class OrderSplitJob extends IJobHandler {

    private Logger logger =  LoggerFactory.getLogger(this.getClass());

    @Autowired
    SchedulService schedulService;

    /**
     * 每半小时执行一次
     */
    @Override
    public ReturnT<String> execute(String... strings) throws Exception {
        try {
            XxlJobLogger.log("开始生产拆分订单消息到队列");
            schedulService.productSplitMessage();
            XxlJobLogger.log("生产拆分订单消息到队列结束");
        }catch ( Exception e ){
            logger.error("生产消息失败", e);
            XxlJobLogger.log("生产消息失败");
            return ReturnT.FAIL;
        }
        return ReturnT.SUCCESS;
    }
}
